package com.bysc.cmsservice.Listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.bysc.cmsservice.entity.CmsCourse;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

// Excel 读取监听器
@Component
public class CourseExcelListener extends AnalysisEventListener<CmsCourse> {
    private List<CmsCourse> courses = new ArrayList<>();

    @Override
    public void invoke(CmsCourse course, AnalysisContext analysisContext) {
        courses.add(course);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        // 读取完成后的操作
    }

    public List<CmsCourse> getCourses() {
        return courses;
    }
}

